package com.neusoft.nepg.gridders.controller;

import com.neusoft.nepg.gridders.entity.Feedback;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

import java.io.IOException;

public class CardViewController {
    @FXML
    private Label level;
    @FXML
    private Button getIn;
    @FXML
    private Label address;
    @FXML
    private Label LocationAndTimes;
    //current frame
    @FXML
    private VBox vBox;

    private Feedback feedback;

    public void setData(Feedback feedbacks) {
        feedback = feedbacks;
        this.level.setText(feedback.getLevel());
        this.address.setText(feedback.getAddress());
        this.LocationAndTimes.setText( feedback.getProvince() + " " + feedback.getCity() + " " + feedback.getData());
    }

    public void getVBox(VBox vBox) {
        this.vBox = vBox;
    }

    @FXML
    public void getIn() {
        try {
            FXMLLoader loader = new FXMLLoader(getClass().getResource("../view/FeedbackInfoView.fxml"));

            FeedbackInfoViewController controller = (FeedbackInfoViewController) loader.getController();
            controller.initial(feedback);

            Parent root = loader.load();
            Stage stage = (Stage) vBox.getScene().getWindow();
            Scene scene = new Scene(root);
            stage.setScene(scene);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
